package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.vo.SjModelCountVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SjModelMapper;
import com.ruoyi.system.domain.SjModel;
import com.ruoyi.system.service.ISjModelService;

/**
 * 审计模型库Service业务层处理
 * 
 * @author zrr
 * @date 2024-11-04
 */
@Service
public class SjModelServiceImpl implements ISjModelService 
{
    @Autowired
    private SjModelMapper sjModelMapper;

    /**
     * 查询审计模型库
     * 
     * @param id 审计模型库主键
     * @return 审计模型库
     */
    @Override
    public SjModel selectSjModelById(Integer id)
    {
        return sjModelMapper.selectSjModelById(id);
    }

    /**
     * 查询审计模型库列表
     * 
     * @param sjModel 审计模型库
     * @return 审计模型库
     */
    @Override
    public List<SjModel> selectSjModelList(SjModel sjModel)
    {
        return sjModelMapper.selectSjModelList(sjModel);
    }

    /**
     * 新增审计模型库
     * 
     * @param sjModel 审计模型库
     * @return 结果
     */
    @Override
    public int insertSjModel(SjModel sjModel)
    {
        sjModel.setCreateTime(DateUtils.getNowDate());
        return sjModelMapper.insertSjModel(sjModel);
    }

    /**
     * 修改审计模型库
     * 
     * @param sjModel 审计模型库
     * @return 结果
     */
    @Override
    public int updateSjModel(SjModel sjModel)
    {
        sjModel.setUpdateTime(DateUtils.getNowDate());
        return sjModelMapper.updateSjModel(sjModel);
    }

    /**
     * 批量删除审计模型库
     * 
     * @param ids 需要删除的审计模型库主键
     * @return 结果
     */
    @Override
    public int deleteSjModelByIds(Integer[] ids)
    {
        return sjModelMapper.deleteSjModelByIds(ids);
    }

    /**
     * 删除审计模型库信息
     * 
     * @param id 审计模型库主键
     * @return 结果
     */
    @Override
    public int deleteSjModelById(Integer id)
    {
        return sjModelMapper.deleteSjModelById(id);
    }

    /**
     * 查询审计模型库数量
     * @return
     */
    @Override
    public List<SjModelCountVO> selectSjModelCountList() {
        List<SjModelCountVO> modelCountList = sjModelMapper.selectSjModelCount();
        Integer count = 0;
        for (SjModelCountVO sjModelCountVO : modelCountList) {
            count = count + sjModelCountVO.getCount();
        }
        SjModelCountVO sjModelCountVO = new SjModelCountVO("总数", count);
        modelCountList.add(sjModelCountVO);
        return modelCountList;
    }

}
